-- 
--  User Defined Function: udf_SystemInfo_find
--   Description: checks if an entry exists on the table SystemInfo.
--   Parameters:
--     @name - host name
--   Return value: id of the entry that has the SystemInfo.Name equal to @name, or
--                 NULL if that entry can't be found.
-- 
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'udf_SystemInfo_find')
  DROP FUNCTION udf_SystemInfo_find
GO
CREATE FUNCTION udf_SystemInfo_find (@name varchar(30))
RETURNS int
AS
BEGIN
  DECLARE @ID int = NULL
  SELECT @ID=ID FROM SystemInfo WHERE Name=@name
  RETURN @ID
END
GO

